import dt from '@dt/dt'
import paramsMgr from '@/biz/bonus/params.js'

function options(_this) {
  let opt = [
    [{
      key: 'defaultCounselorRoomRule',
      title: '默认非顾问房源确认规则',
      col: 8,
      select: {
        key: 'effectiveWay'
      }
    }, {
      col: 3,
      button: {
        title: '新增岗位设置',
        type: 'primary',
        ghost: true,
        click: () => {
          _this.list.push({
            postIds: [],
            rule: '2'
          })
        }
      }
    }]
  ]
  return opt
}

function columns(_this, flag) {
  return [{
      type: 'index',
      title: '序号',
      width: 60
    },
    {
      title: '岗位',
      cell: (row) => {
        let options = paramsMgr.positions(_this.list, row)
        options = options.filter(i => i.value != '置业顾问')
        return {
          edit: {
            key: 'postIds',
            placeholder: '请选择岗位(多选)',
            select: {
              options,
              multiple: true,
              maxTagCount: 1
            }
          }
        }
      }
    },
    {
      title: '确认规则',
      width: 200,
      cell: {
        edit: {
          key: 'rule',
          select: {
            key: 'effectiveWay'
          }
        }
      }
    },
    {
      field: 'handles',
      title: '操作',
      width: 70,
      cell: (row) => {
        return {
          btn: [{
            title: '删除',
            event: 'onDelete',
          }]
        }
      }
    }
  ]
}

function helps() {
  return [{
      label: '非顾问房源确认规则',
      value: ['设置后，非顾问岗位按照配置项，确定房源归属']
    }, {
      label: '默认非顾问房源确认规则',
      value: ['配置后，所有非顾问岗位按此配置日期确认房源归属']
    }, {
      label: '新增岗位设置',
      value: ['可选择不同岗位设置不同的确认规则，未设置的岗位按默认非顾问房源确认规则确定归属']
    }, {
      label: '参考配置',
      value: ['非顾问其他岗位按“签约日期”确定房源归属']
    }, {
      tips: '以上配置在保存后即时生效，不影响已发起奖金单',
    },
  ]
}

export default {
  options,
  columns,
  helps
}
